package net.hn.hnms.biz.video.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.video.domain.Camera;
import net.hn.hnms.biz.video.domain.CameraStream;
import net.hn.hnms.biz.video.domain.CameraTree;
import net.hn.hnms.biz.video.domain.VideoInfo;
import net.hn.hnms.biz.video.service.IHikVisionService;
import net.hn.hnms.sys.common.core.domain.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @Author mkq
 * @Date 2022-08-04 10:15
 * @Description
 */
@RestController
@Api(tags = "海康开放平台接口")
@RequestMapping("/hik")
public class HikVersionController {

    @Resource
    IHikVisionService hikVisionService;


    @ApiOperation("获取所有摄像头信息")
    @GetMapping("/list")
    public R<List<Camera>> list() {
        return R.ok(hikVisionService.list());
    }


    @ApiOperation("获取摄像头取流URL")
    @GetMapping("/getStreamUrl")
    public R<String> getStreamUrl(CameraStream cameraStream){
        return R.ok("获取成功",hikVisionService.getStreamUrl(cameraStream));
    }




    @ApiOperation("获取所有摄像头信息")
    @GetMapping("/treeList")
    public R<CameraTree> treeList() {
        return R.ok(hikVisionService.treeList());
    }



    @ApiOperation("获取摄像头取流URLs")
    @GetMapping("/getStreamUrls")
    public R<List<VideoInfo>> getStreamUrls(String code) {
        List<String> codes = Arrays.asList(code.split(","));
        return R.ok("获取成功", hikVisionService.getStreamUrls(codes));
    }



}
